/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jeelabs.lab2;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ApplicationScoped;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;

/**
 *
 * @author bastian
 */
@ManagedBean(name="emfHelper", eager=true)
@ApplicationScoped
public class EntityManagerFactoryHelper {

    @PersistenceUnit
    private EntityManagerFactory emf;

    /** Creates a new instance of EntityManagerFactoryHelper */
    public EntityManagerFactoryHelper() {
    }

    @PostConstruct
    public void putEmf() {
        FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().put("emf", emf);
    }
}
